package hc.bre.rest.admin

import hc.bre.cmn.ListOption

@groovy.transform.CompileStatic
@groovy.transform.ToString(includeNames=true,includePackage=false)
class BreUser extends ListOption implements Serializable{
	String password;
	String salt;
	Set<Integer> roleIds = [];

	boolean forbidden

	@com.fasterxml.jackson.annotation.JsonIgnore
	Set<String> perms ;

	@Override
	public BreUser load(Map map) {
		super.load(map);
		password = map['password'];
		salt = map['salt'];

		//from the front-end user's input
		def inputedPwd = map['inputedPwd'] as String
		if(inputedPwd && inputedPwd != '@been changed@')
		{
			AuthUtil.updatePassword(this,inputedPwd);
		}

		roleIds = hc.Util.loadValueSet(map['roleIds'], Integer.class);

		forbidden = map['forbidden']?true:false;;

		return this;
	}
}
